<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ page import="crm.model.Notice" %>
<%@ page import="crm.control.NoticeControl"%>
<%@page import="crm.util.ParamUtil"%>
<%@ page import="crm.model.Employees" %>
<%@ page import = "crm.control.DateControl" %>
<%@ page import="java.util.*"  %>
<html>
<body>
<% 
Employees cu = (Employees)session.getAttribute("user");
int  userType  = ParamUtil.getInt(request,"userType",cu.getPosition());;
request.setCharacterEncoding("UTF-8"); 
Notice notice = new Notice(); 
DateControl dc = new DateControl();
String theme = request.getParameter("theme"); 
notice.setTheme(theme); 
String time = dc.Date();

notice.setTime(time); 
 
if(userType!=1)
notice.setWriter(cu.getId()); 
 
String content = request.getParameter("content"); 
notice.setContent(content); 
 
 
NoticeControl nc = new NoticeControl(); 
 
if(nc.insertNotice(notice)) 
{ 
	%>	
<script language = "javascript">
if(window.confirm("录入成功，是否继续公告？"))
window.location.href = "notice_add.jsp";
else
window.top.location.href = "notice.jsp";
</script>
<%} else { %>
<script language="javascript">
if(window.confirm("录入失败，是否继续录入？"))
window.location.href = "notice_add.jsp";
else
window.top.location.href = "notice.jsp";
</script>
<%
	}
%>
</body>
</html>
